package vn.sunnet.game.SinhTon.object;

import vn.sunnet.game.SinhTon.global.Assets;

import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.math.Vector2;

// Con boss nay di ra sau do se ban
public class Boss11 extends Boss {
	float stateTime;
	private float timeDie;
	private float timeDelay;

	public Boss11() {
		setAnimation(Assets.atBoss11);
		setScore(50);
		switch (Assets.map) {
		case 2:
			setHp(600);
			setDamageSpeed(500);
			setBounds(new Rectangle(200, 480, 160, 144));
			setVelocity(new Vector2(0, 40));
			break;
		case 4:
			setHp(700);
			setDamageSpeed(600);
			setBounds(new Rectangle(385, 480, 160, 144));
			setVelocity(new Vector2(0, 50));
			break;
		case 6:
			setHp(800);
			setDamageSpeed(700);
			setBounds(new Rectangle(240, 480, 160, 144));
			setVelocity(new Vector2(0, 60));
			break;
		case 8:
			setHp(900);
			setDamageSpeed(800);
			setBounds(new Rectangle(360, 480, 160, 144));
			setVelocity(new Vector2(0, 70));
			break;
		case 10:
			setHp(1000);
			setDamageSpeed(1000);
			setBounds(new Rectangle(290, 480, 160, 144));
			setVelocity(new Vector2(0, 80));
			break;
		default:
			break;
		}
	}

	@Override
	void move(float time, int speed) {
		// di chuyen
		if (getBounds().y > 200) {
			switch (Assets.map) {
			case 2:
				getBounds().y -= time * getVelocity().y * speed;
				getBounds().x += time * getVelocity().y * speed / 3;
				break;
			case 4:
				getBounds().y -= time * getVelocity().y * speed;
				getBounds().x -= time * getVelocity().y * speed / 5;
				break;
			case 6:
				getBounds().y -= time * getVelocity().y * speed;
				getBounds().x += time * getVelocity().y * speed / 4;
				break;
			case 8:
				getBounds().y -= time * getVelocity().y * speed;
				break;
			case 10:
				getBounds().y -= time * getVelocity().y * speed;
				break;
			default:
				break;
			}

		} else {
			setState_Boss(1);
		}
	}

	@Override
	public void shot(int dame) {
		float hp = getHp() - 2 * dame;
		setHp(hp);
		if (getHp() <= 0) {
			setState_Boss(2);
		}
	}

	@Override
	public TextureRegion getTexture() {
		return getAnimation().getKeyFrame(stateTime, true);
	}

	/**
	 * @param time
	 * @param speed
	 *            toc do cua Boss(khi dong bang cho = 0)
	 */
	public void update(float time, int speed) {
		stateTime += 0.5 * time;
		timeDelay += time;
		switch (getState_Boss()) {
		case 0:
			if (timeDelay > 2)
				move(time, speed);
			break;

		case 1:

			break;
		case 2:
			// this.setBounds(new Rectangle(0, 0, 0, 0));
			timeDie += 0.5f * time;
			// Cho thoi gian chet cua Zombie laf 0.4
			if (timeDie > 0.4) {
				// Sau 0.4s tu luc chet thi se xoa zombie
				// setRemove(true);
				setState_Boss(3);
			}
			break;
		case 3:
			break;
		}

	}
}
